Example #1
0
    def SetDbItem(self, dbitem):
        # remove return and adjust to your db
        # this loads an existing design from the db
        return

        self.dbItemRack = dbitem
        # load diagram from db
        if self.dbItemRack.shapeinfo:
            xmlDoc = binderytools.bind_string(self.dbItemRack.shapeinfo)
            if hasattr(xmlDoc.shapes, "RectangleShape"):
                for shape in xmlDoc.shapes.RectangleShape:
                    x = float(str(shape.x))
                    y = float(str(shape.y))
                    width = float(str(shape.width))
                    height = float(str(shape.height))
                    newShape = self.designWindow.MyAddShape(
                        RectangleShape(width, height), x, y, wx.BLACK_PEN, wx.LIGHT_GREY_BRUSH, ""
                    )
                    newShape.SetRackItemId(int(str(shape.rackitemid)))
                    if newShape.GetRackItemId() != 0:
                        bin = (
                            wx.GetApp()
                            .Getds()
                            .selectByPrimaryKey(beans.winerackb, newShape.GetRackItemId())
                        )
                        shapetip = "Bin no: %i, Sub-bin no: %i, Capacity: %i, Description: %s" % (
                            bin.binno,
                            bin.subbinno,
                            bin.capacity,
                            bin.description,
                        )
                        newShape.SetShapeTip(shapetip)
                    newShape.GetCanvas().Refresh()
            if hasattr(xmlDoc.shapes, "PolygonShape"):
                for shape in xmlDoc.shapes.PolygonShape:
                    x = float(str(shape.x))
                    y = float(str(shape.y))
                    width = float(str(shape.width))
                    height = float(str(shape.height))
                    shapePoints = []
                    for point in shape.points.point:
                        shapePoints.append((float(str(point.x)), float(str(point.y))))
                    newShape = self.designWindow.MyAddShape(
                        PolygonShape(width, height), x, y, wx.BLACK_PEN, wx.LIGHT_GREY_BRUSH, ""
                    )
                    newShape.Create(shapePoints)
                    newShape.SetRackItemId(int(str(shape.rackitemid)))
                    if newShape.GetRackItemId() != 0:
                        bin = (
                            wx.GetApp()
                            .Getds()
                            .selectByPrimaryKey(beans.winerackb, newShape.GetRackItemId())
                        )
                        shapetip = "Bin no: %i, Sub-bin no: %i, Capacity: %i" % (
                            bin.binno,
                            bin.subbinno,
                            bin.capacity,
                        )
                        newShape.SetShapeTip(shapetip)
                    newShape.GetCanvas().Refresh()
Example #2
0
 def SetDbItem(self, dbitem):
     # remove return and adjust to your db
     # this loads an existing design from the db
     return
 
     self.dbItemRack = dbitem
     # load diagram from db
     if self.dbItemRack.shapeinfo:
         xmlDoc = binderytools.bind_string(self.dbItemRack.shapeinfo)
         if hasattr(xmlDoc.shapes, 'RectangleShape'):
             for shape in xmlDoc.shapes.RectangleShape:
                 x = float(unicode(shape.x))
                 y = float(unicode(shape.y))
                 width = float(unicode(shape.width))
                 height = float(unicode(shape.height))
                 newShape = self.designWindow.MyAddShape(RectangleShape(width, height), 
                     x, y, wx.BLACK_PEN, wx.LIGHT_GREY_BRUSH, "")
                 newShape.SetRackItemId(int(unicode(shape.rackitemid)))
                 if newShape.GetRackItemId() != 0:
                     bin = wx.GetApp().Getds().selectByPrimaryKey(beans.winerackb,
                                                                  newShape.GetRackItemId())
                     shapetip = 'Bin no: %i, Sub-bin no: %i, Capacity: %i, Description: %s' % (
                                                                         bin.binno,
                                                                         bin.subbinno,
                                                                         bin.capacity,
                                                                         bin.description)
                     newShape.SetShapeTip(shapetip)
                 newShape.GetCanvas().Refresh()
         if hasattr(xmlDoc.shapes, 'PolygonShape'):
             for shape in xmlDoc.shapes.PolygonShape:
                 x = float(unicode(shape.x))
                 y = float(unicode(shape.y))
                 width = float(unicode(shape.width))
                 height = float(unicode(shape.height))
                 shapePoints = []
                 for point in shape.points.point:
                     shapePoints.append((float(unicode(point.x)), 
                                         float(unicode(point.y))))
                 newShape = self.designWindow.MyAddShape(PolygonShape(width, height), 
                     x, y, wx.BLACK_PEN, wx.LIGHT_GREY_BRUSH, "")
                 newShape.Create(shapePoints)
                 newShape.SetRackItemId(int(unicode(shape.rackitemid)))
                 if newShape.GetRackItemId() != 0:
                     bin = wx.GetApp().Getds().selectByPrimaryKey(beans.winerackb,
                                                                  newShape.GetRackItemId())
                     shapetip = 'Bin no: %i, Sub-bin no: %i, Capacity: %i' % (bin.binno,
                                                                         bin.subbinno,
                                                                         bin.capacity)
                     newShape.SetShapeTip(shapetip)
                 newShape.GetCanvas().Refresh()
Example #3
0
    def Load(self, a_sFilename=None):
        if a_sFilename <> None:
            self.SetFilename(a_sFilename)
        else:
            if self.m_sFilename == None:
                self.m_sFilename = "Cannot Load without filename"
                return False

        #reseting present diagram..
        self.m_oBlocks,self.m_oConnectors,self.m_oCurrConnector,self.m_nSessionId = {},[],None,0

        #this two must be updated at each block/conn insertion
        self.m_nBlockCountId = 1  #since block counts are kept, render this from the saved file
        self.m_nConnectorCountId = 1  #since connector Ids are generated from scratch, just reset it

        t_oLoad = bt.bind_file(self.m_sFilename)  #binding saved project

        #loading blocks on canvas
        for block in t_oLoad.harpia.GcState.block:
            self.InsertBlockPosId(int(block.type), float(block.position.x),
                                  float(block.position.y), int(block.id))
            self.m_nBlockCountId = max(self.m_nBlockCountId, int(block.id))
        self.m_nBlockCountId += 1

        #loading connectors on canvas
        try:
            for block in t_oLoad.harpia.network.block:
                for connector in block.outputs.output:
                    if connector.inBlock <> "--" and connector.input <> "--":
                        self.InsertReadyConnector(int(block.id),
                                                  (int(connector.id) - 1),
                                                  int(connector.inBlock),
                                                  (int(connector.input) - 1))
                        #this "-1" are "paired" with those "+1" at line 286 (GetProcessChain:offset=14)
        except AttributeError:
            pass

        #loading properties
        for block in t_oLoad.harpia.properties.block:
            t_sBlockProperties = '<?xml version="1.0" encoding="UTF-8"?>\n<properties>\n' + block.xml(
            ) + '\n</properties>\n'
            self.m_oBlocks[int(block.id)].SetPropertiesXML(
                bt.bind_string(t_sBlockProperties))

        self.UpdateScrolling()
        self.GotoScrolling(0, 0)
        return True
Example #4
0
    def OnTBSave(self, event):
        if len(self.shapes) > 0:
            # create xml and write to db
            doc_header = """<shapes></shapes>"""
            xmlDoc = binderytools.bind_string(doc_header)
            for shape in self.shapes:
                shape.Save(xmlDoc)

            # self.dbItemRack.shapeinfo = xmlDoc.xml(indent=u'yes')
            # adjust above to your db and remove below
            print(xmlDoc.xml(indent="yes"))
        else:
            pass
            # adjust to your db
            # self.dbItemRack.shapeinfo = ''

        # adjust to your db
        # wx.GetApp().Getds().commit()
        self.dataToSave = False
Example #5
0
 def OnTBSave(self, event):
     if len(self.designWindow.shapes) > 0:
         # create xml and write to db
         doc_header = '''<shapes></shapes>'''
         xmlDoc = binderytools.bind_string(doc_header)
         for shape in self.designWindow.shapes:
             shape.Save(xmlDoc)
 
         #self.dbItemRack.shapeinfo = xmlDoc.xml(indent=u'yes')
         # adjust above to your db and remove below
         print xmlDoc.xml(indent=u'yes')
     else:
         pass
         # adjust to your db
         #self.dbItemRack.shapeinfo = ''
     
     # adjust to your db
     #wx.GetApp().Getds().commit()
     self.dataToSave = False
Example #6
0
	def Load( self, a_sFilename=None ):
		if a_sFilename <> None:
			self.SetFilename(a_sFilename)
		else:
			if self.m_sFilename == None:
				self.m_sFilename = "Cannot Load without filename"
				return False
		
		#reseting present diagram.. 
		self.m_oBlocks,self.m_oConnectors,self.m_oCurrConnector,self.m_nSessionId = {},[],None,0
		
		#this two must be updated at each block/conn insertion
		self.m_nBlockCountId = 1 #since block counts are kept, render this from the saved file
		self.m_nConnectorCountId = 1 #since connector Ids are generated from scratch, just reset it
		
		t_oLoad = bt.bind_file(self.m_sFilename) #binding saved project
		
		#loading blocks on canvas
		for block in t_oLoad.harpia.GcState.block:
			self.InsertBlockPosId(int(block.type),float(block.position.x),float(block.position.y),int(block.id))
			self.m_nBlockCountId = max(self.m_nBlockCountId,int(block.id))
		self.m_nBlockCountId += 1
			
		#loading connectors on canvas
		try:
			for block in t_oLoad.harpia.network.block:
				for connector in block.outputs.output:
					if connector.inBlock <> "--" and connector.input <> "--":
						self.InsertReadyConnector(int(block.id), (int(connector.id)-1), int(connector.inBlock), (int(connector.input)-1)) 
						#this "-1" are "paired" with those "+1" at line 286 (GetProcessChain:offset=14)
		except AttributeError:
			pass
		
		#loading properties
		for block in t_oLoad.harpia.properties.block:
			t_sBlockProperties = '<?xml version="1.0" encoding="UTF-8"?>\n<properties>\n' + block.xml() + '\n</properties>\n'
			self.m_oBlocks[int(block.id)].SetPropertiesXML(bt.bind_string(t_sBlockProperties))
		
		self.UpdateScrolling()
		self.GotoScrolling(0,0);
		return True
Example #7
0
    def LoadFromXML(self):
        # create xml and write to db
        doc_header = """<shapes>
  <RectangleShape>
    <width>100.0</width>
    <height>100.0</height>
    <x>170.0</x>
    <y>96.0</y>
    <rackitemid>113</rackitemid>
  </RectangleShape>
  <PolygonShape>
    <points>
      <point>
        <x>-122</x>
        <y>196</y>
      </point>
      <point>
        <x>-22</x>
        <y>96</y>
      </point>
      <point>
        <x>-122</x>
        <y>96</y>
      </point>
    </points>
    <rackitemid>114</rackitemid>
  </PolygonShape>
  <PolygonShape>
    <points>
      <point>
        <x>-124</x>
        <y>96</y>
      </point>
      <point>
        <x>-224</x>
        <y>196</y>
      </point>
      <point>
        <x>-124</x>
        <y>196</y>
      </point>
    </points>
    <rackitemid>115</rackitemid>
  </PolygonShape>
</shapes>"""
        xmlDoc = binderytools.bind_string(doc_header)
        if hasattr(xmlDoc.shapes, "RectangleShape"):
            for shape in xmlDoc.shapes.RectangleShape:
                x = float(str(shape.x))
                y = float(str(shape.y))
                w = float(str(shape.width))
                h = float(str(shape.height))
                rid = str(shape.rackitemid)
                if rid != 0:
                    shapetip = "some dummy info for rectangle which normally comes from db"
                else:
                    shapetipe = ""

                shape = RectangleShape((x, y), (w, h), "Red", rid, shapetip)
                self.Canvas.AddObject(shape)
                shape.Bind(FC.EVT_FC_LEFT_DOWN, self.MoveRect)
                self.dataToSave = True
                self.shapes.append(shape)

        if hasattr(xmlDoc.shapes, "PolygonShape"):
            for shape in xmlDoc.shapes.PolygonShape:
                shapePoints = []
                for point in shape.points.point:
                    shapePoints.append(
                        (float(str(point.x)), float(str(point.y))))
                Points = N.array(shapePoints, N.float_)

                rid = str(shape.rackitemid)
                if rid != 0:
                    shapetip = "some dummy info for triangle which normally comes from db"
                else:
                    shapetip = ""

                shape = TriangleShape(Points, "Red", rid, shapetip)
                self.Canvas.AddObject(shape)
                shape.Bind(FC.EVT_FC_LEFT_DOWN, self.MovePoly)
                self.dataToSave = True
                self.shapes.append(shape)

        self.Canvas.Draw()
Example #8
0
	def ReturnResponse(self ):
		t_oResponse = bt.bind_string(self.HARPIARESPONSE)
		return t_sResponse
Example #9
0
 def ReturnResponse(self):
     t_oResponse = bt.bind_string(self.HARPIARESPONSE)
     return t_sResponse
Example #10
0
    def LoadFromXML(self):
        # create xml and write to db
        doc_header = '''<shapes>
  <RectangleShape>
    <width>100.0</width>
    <height>100.0</height>
    <x>170.0</x>
    <y>96.0</y>
    <rackitemid>113</rackitemid>
  </RectangleShape>
  <PolygonShape>
    <points>
      <point>
        <x>-122</x>
        <y>196</y>
      </point>
      <point>
        <x>-22</x>
        <y>96</y>
      </point>
      <point>
        <x>-122</x>
        <y>96</y>
      </point>
    </points>
    <rackitemid>114</rackitemid>
  </PolygonShape>
  <PolygonShape>
    <points>
      <point>
        <x>-124</x>
        <y>96</y>
      </point>
      <point>
        <x>-224</x>
        <y>196</y>
      </point>
      <point>
        <x>-124</x>
        <y>196</y>
      </point>
    </points>
    <rackitemid>115</rackitemid>
  </PolygonShape>
</shapes>'''
        xmlDoc = binderytools.bind_string(doc_header)
        if hasattr(xmlDoc.shapes, 'RectangleShape'):
            for shape in xmlDoc.shapes.RectangleShape:
                x = float(unicode(shape.x))
                y = float(unicode(shape.y))
                w = float(unicode(shape.width))
                h = float(unicode(shape.height))
                rid = (unicode(shape.rackitemid))
                if rid != 0:
                    shapetip = 'some dummy info for rectangle which normally comes from db'
                else:
                    shapetipe = ''
    
                shape = RectangleShape((x, y), (w, h), "Red", rid, shapetip)
                self.Canvas.AddObject(shape)
                shape.Bind(FC.EVT_FC_LEFT_DOWN, self.MoveRect)
                self.dataToSave = True
                self.shapes.append(shape)

        if hasattr(xmlDoc.shapes, 'PolygonShape'):
            for shape in xmlDoc.shapes.PolygonShape:
                shapePoints = []
                for point in shape.points.point:
                    shapePoints.append((float(unicode(point.x)), 
                                        float(unicode(point.y))))
                Points = N.array(shapePoints,
                                 N.float_)
                                 
                rid = (unicode(shape.rackitemid))
                if rid != 0:
                    shapetip = 'some dummy info for triangle which normally comes from db'
                else:
                    shapetip = ''

                shape = TriangleShape(Points, "Red", rid, shapetip)
                self.Canvas.AddObject(shape)
                shape.Bind(FC.EVT_FC_LEFT_DOWN, self.MovePoly)
                self.dataToSave = True
                self.shapes.append(shape)
        
        self.Canvas.Draw()