Example #1
0
 def __init__(self, handle = None):
     self.idx = 0
     self.log = logging.getConsoleLogger(type(self).__name__, lev)
     self.log.disabled = False
     self.log.debug('__init__: Instantiation')
     self._handle = handle 
     if handle:
         self.remoteService = MechanicalService(handle.spinner)
     self.layout = MathStackPanel()
Example #2
0
class Drawing(object):
    def __init__(self, handle = None):
        self.idx = 0
        self.log = logging.getConsoleLogger(type(self).__name__, lev)
        self.log.disabled = False
        self.log.debug('__init__: Instantiation')
        self._handle = handle 
        if handle:
            self.remoteService = MechanicalService(handle.spinner)
        self.layout = MathStackPanel()
    def searchDrawing(self, idx):
        for idxPosition, stackItem in enumerate(self.layout.getChildren()):
            drawing = stackItem.getWidget()
            if int(drawing.idx) == int(idx):
                return drawing, idxPosition
        return None, None
    def actDrawingAdd(self, **kwargs):
        image = kwargs.get('image')
        code = kwargs.get('code')
        perspective = kwargs.get('perspective')
        idx = kwargs.get('idx')
        newDrawing = MechDrawing(self, idx, image, None, code, perspective)
        oldDrawing, _ = self.searchDrawing(idx)
        if oldDrawing:
            self.layout.replace(oldDrawing, newDrawing, perspective)
        else:
            self.layout.add(newDrawing, perspective)
        self.log.debug('actDrawingAdd %s, %s'%(oldDrawing, idx))
    def actSizeFill(self, idx, options, value):
        drawing, _ = self.searchDrawing(idx)
        drawing._optionPanel.actSizeFill(options, value)
    def actUnitFill(self, idx, options, value):
        drawing, _ = self.searchDrawing(idx)
        drawing._optionPanel.actUnitFill(options, value)
    def actSizeSet(self, **kwargs):
        idx = kwargs.get('idx')
        value = kwargs.get('value')
        drawing, _ = self.searchDrawing(idx)
        drawing._optionPanel.actSizeSet(value)
    def actRatioChange(self, idx, ratio):
        drawing, _ = self.searchDrawing(idx)
        drawing._optionPanel.actRatioChange(ratio)           
    def actClear(self, **kwargs):
        self.log.debug('actClear, kwargs %s'%kwargs)
        idx = kwargs.get('idx', None)
        if idx:
            _, idxPosition = self.searchDrawing(idx)
            self.layout.remove(idxPosition)
        else:
            self.layout.clear()
    def actRefresh(self, **kwargs):
        idx = kwargs.get('idx', None)
        self.remoteService.mech_design_get(self._handle, idx)
    def actPass(self, *kwargs):
        self.log.debug('actPass, do nothing')
    def onMenuResume(self):
        self.actRefresh()