Beispiel #1
0
    def doNGLCode(self, **kwargs):
        """ Generate code for NGL_Label """

        # convert coordinates
        g = self._ngl_geometry()

        # get font pointer name
        _, fontPointerName = NGL_Font.formatQFontName(self.font)

        # if label is a static
        if self.static is True:
            template = 'NGL_Font_DrawString({x}, {y}, {color}, {font}, {transparent}, {text});'

            return template.format(
                x = g.x(),
                y = g.y(),
                color = self._ngl_color('color: rgb'),
                font = fontPointerName,
                transparent = 'Transparent',
                text = '"%s"' % self.text)

        # else return label sctruct code
        else:
            import pkg_resources

            res_path = pkg_resources.resource_filename('ngl_utils', 'templates/label.ntp')
            with open(res_path, 'rt') as f:
                template = f.read()

            textVar = 'static char {0}_text[{1}] = "{2}";'.format(
                self.objectName(),
                len(self.text)+1,
                self.text)

            return template.format(
                pageName = self._ngl_parent_obj_name(),
                itemName = self.objectName(),
                x = g.x(),
                y = g.y(),
                color = self._ngl_color('color: rgb'),
                transparent = 'Transparent',
                textVar = textVar,
                text = '(char*)%s_text' % self.objectName(),
                fontName = fontPointerName
            )
Beispiel #2
0
    def doNGLCode(self, **kwargs):
        """ Generate code for NGL_Label """

        # convert coordinates
        g = self._ngl_geometry()

        # get font pointer name
        _, fontPointerName = NGL_Font.formatQFontName(self.font)

        # if label is a static
        if self.static is True:
            template = 'NGL_Font_DrawString({x}, {y}, {color}, {font}, {transparent}, {text});'

            return template.format(x=g.x(),
                                   y=g.y(),
                                   color=self._ngl_color('color: rgb'),
                                   font=fontPointerName,
                                   transparent='Transparent',
                                   text='"%s"' % self.text)

        # else return label sctruct code
        else:
            import pkg_resources

            res_path = pkg_resources.resource_filename('ngl_utils',
                                                       'templates/label.ntp')
            with open(res_path, 'rt') as f:
                template = f.read()

            textVar = 'static char {0}_text[{1}] = "{2}";'.format(
                self.objectName(),
                len(self.text) + 1, self.text)

            return template.format(pageName=self._ngl_parent_obj_name(),
                                   itemName=self.objectName(),
                                   x=g.x(),
                                   y=g.y(),
                                   color=self._ngl_color('color: rgb'),
                                   transparent='Transparent',
                                   textVar=textVar,
                                   text='(char*)%s_text' % self.objectName(),
                                   fontName=fontPointerName)
Beispiel #3
0
    def doNGLCode(self, **kwargs):

        import pkg_resources

        res_path = pkg_resources.resource_filename('ngl_utils',
                                                   'templates/graphscale.ntp')
        with open(res_path, 'rt') as f:
            template = f.read()

        # convert coordinates
        g = self._ngl_geometry()

        # orientation
        ori = {1: 'NGL_Horizontal', 2: 'NGL_Vertical'}

        # get font pointer name
        _, fontPointerName = NGL_Font.formatQFontName(self.font)

        return template.format(pageName=self._ngl_parent_obj_name(),
                               itemName=self.objectName(),
                               x0=g.x(),
                               y0=g.y(),
                               x1=g.x() + g.width() - 1,
                               y1=g.y() + g.height() - 1,
                               minimum=self.minimum,
                               maximum=self.maximum,
                               scalecent=self.scaleCent,
                               labels='{%s}' % self.labels,
                               labels_cnt=len(self.labels.split(',')),
                               units='"%s"' % self.units,
                               showlabels=self.showLabels,
                               showlines=self.showLines,
                               flip=self.flip,
                               orientation=ori[self.orientation],
                               font=fontPointerName,
                               color=self._ngl_color('color: rgb'))
Beispiel #4
0
    def doNGLCode(self, **kwargs):

        import pkg_resources

        res_path = pkg_resources.resource_filename('ngl_utils', 'templates/checkbox.ntp')
        with open(res_path, 'rt') as f:
            template = f.read()

        # convert coordinates
        g = self._ngl_geometry()

        # get font pointer name
        _, fontPointerName = NGL_Font.formatQFontName(self.font)

        # text var
        __text_var_name = self.objectName().lower() + '_text'
        __text_var = 'static const char {0}[{1}] = "{2}";'.format(__text_var_name,
                                                                  len(self._text)+1,
                                                                  self._text)
        __text_pointer = __text_var_name

        return template.format(
            pageName = self._ngl_parent_obj_name(),
            itemName = self.objectName(),
            text_var = __text_var,
            x0 = g.x(),
            y0 = g.y(),
            x1 = g.x() + g.width() - 1,
            y1 = g.y() + g.height() - 1,
            checked = self._checked,
            font_pointer = fontPointerName.replace('(NGL_Font*)', ''),
            text_pointer = __text_pointer,
            color = hex(NGL_Colors.fromQColor(self._color)),
            text_color = self._ngl_color('color: rgb'),
            p_event = self.clickEventName
        )
Beispiel #5
0
    def doNGLCode(self, **kwargs):

        import pkg_resources

        res_path = pkg_resources.resource_filename('ngl_utils', 'templates/graphscale.ntp')
        with open(res_path, 'rt') as f:
            template = f.read()

        # convert coordinates
        g = self._ngl_geometry()

        # orientation
        ori = {1: 'NGL_Horizontal', 2: 'NGL_Vertical'}

        # get font pointer name
        _, fontPointerName = NGL_Font.formatQFontName(self.font)

        return template.format(
                pageName = self._ngl_parent_obj_name(),
                itemName = self.objectName(),
                x0 = g.x(),
                y0 = g.y(),
                x1 = g.x() + g.width() - 1,
                y1 = g.y() + g.height() - 1,
                minimum = self.minimum,
                maximum = self.maximum,
                scalecent = self.scaleCent,
                labels = '{%s}' % self.labels,
                labels_cnt = len(self.labels.split(',')),
                units = '"%s"' % self.units,
                showlabels = self.showLabels,
                showlines = self.showLines,
                flip = self.flip,
                orientation = ori[self.orientation],
                font = fontPointerName,
                color = self._ngl_color('color: rgb'))
Beispiel #6
0
    def doNGLCode(self, **kwargs):

        import pkg_resources

        res_path = pkg_resources.resource_filename('ngl_utils',
                                                   'templates/checkbox.ntp')
        with open(res_path, 'rt') as f:
            template = f.read()

        # convert coordinates
        g = self._ngl_geometry()

        # get font pointer name
        _, fontPointerName = NGL_Font.formatQFontName(self.font)

        # text var
        __text_var_name = self.objectName().lower() + '_text'
        __text_var = 'static const char {0}[{1}] = "{2}";'.format(
            __text_var_name,
            len(self._text) + 1, self._text)
        __text_pointer = __text_var_name

        return template.format(pageName=self._ngl_parent_obj_name(),
                               itemName=self.objectName(),
                               text_var=__text_var,
                               x0=g.x(),
                               y0=g.y(),
                               x1=g.x() + g.width() - 1,
                               y1=g.y() + g.height() - 1,
                               checked=self._checked,
                               font_pointer=fontPointerName.replace(
                                   '(NGL_Font*)', ''),
                               text_pointer=__text_pointer,
                               color=hex(NGL_Colors.fromQColor(self._color)),
                               text_color=self._ngl_color('color: rgb'),
                               p_event=self.clickEventName)