Exemplo n.º 1
0
    def _validate_units(self, units):
        '''
        Validate the units of the alignment, ensuring it matches the document
        '''

        if units is None:
            print('Missing units')
            return ''

        xml_units = units[0].attrib['linearUnit']

        if xml_units != Units.get_doc_units()[1]:
            self.errors.append('Document units of ' +
                               Units.get_doc_units()[1] +
                               ' expected, units of ' + xml_units + 'found')
            return ''

        return xml_units
    def _update_alignment(self, value):

        subset = self.data['Alignments'][value]

        if subset['meta'].get('StartStation'):
            self.panel.startStationValueLabel.setText('{0:.2f}'.format(subset['meta']['StartStation']))

        if subset['meta'].get('Length'):
            self.panel.lengthTitleLabel.setText('Length ({0:s}):'.format(Units.get_doc_units()[0]))
            self.panel.lengthValueLabel.setText('{0:.2f}'.format(subset['meta']['Length']))

        sta_model = []

        if subset['station']:
            for st_eq in subset['station']:
                sta_model.append([st_eq['Back'], st_eq['Ahead']])

        widget_model = WidgetModel.create(sta_model, ['Back'], ['Ahead'])

        self.panel.staEqTableView.setModel(widget_model)

        curve_model = []

        for curve in subset['geometry']:

            _vals = [curve[_k] if curve.get(_k) else 0.0 for _k in [
                        'Direction', 'StartStation', 'BearingIn', 'BearingOut', 'Radius']
                    ]

            row = '{0:s}, {1:f}, {2:.2f}, {3:.2f}, {4:.2f}, {5:.2f}'.format(
                curve['Type'], _vals[0], _vals[1], _vals[2], _vals[3], _vals[4]
                )
                #curve['Type'], curve['Direction'], curve['StartStation'],
                #curve['BearingIn'], curve['BearingOut'], curve['Radius']
            #)
            curve_model.append(row.split(','))

        widget_model_2 = WidgetModel.create(curve_model, ['Type', 'Dir', 'Start',
                                                          'In', 'Out', 'Radius'])

        self.panel.curveTableView.setModel(widget_model_2)
        self.panel.curveTableView.resizeColumnsToContents()
Exemplo n.º 3
0
    def write_xml(self):
        '''
        Serialize the object data and it's children to xml files
        '''

        _list = []

        #iterate the list of children, acquiring their data sets
        #and creating a total data set for alignments.
        for _obj in self.Object.OutList:
            _list.append(_obj.Proxy.get_geometry())

        exporter = AlignmentExporter()

        template_path = App.getUserAppDataDir() + 'Mod/freecad-transportation-wb/Resources/data/'
        template_file = 'landXML-' + Units.get_doc_units()[1] + '.xml'

        xml_path = App.ActiveDocument.TransientDir + '/alignment.xml'

        print('writing xml...')
        exporter.write(_list, template_path + template_file, xml_path)

        self.Object.Xml_Path = xml_path