def view(self, viewTblELR=None, newInstance=None):
        startedAt = time.time()
        self.blockMenuEvents += 1
        if newInstance is not None:
            self.modelXbrl = newInstance # a save operation has created a new instance to use subsequently
            clearZchoices = False
        if viewTblELR:  # specific table selection
            self.tblELR = viewTblELR
            clearZchoices = True
        else:   # first or subsequenct reloading (language, dimensions, other change)
            clearZchoices = self.zOrdinateChoices is None
            if clearZchoices: # also need first time initialization
                self.loadTablesMenu()  # load menus (and initialize if first time
            viewTblELR = self.tblELR
            
        if not self.tblELR:
            return  # no table to display

        if clearZchoices:
            self.zOrdinateChoices = {}

        # remove old widgets
        self.viewFrame.clearGrid()

        tblAxisRelSet, xTopStructuralNode, yTopStructuralNode, zTopStructuralNode = resolveAxesStructure(self, viewTblELR) 
        
        if tblAxisRelSet:
            #print("tbl hdr width rowHdrCols {0}".format(self.rowHdrColWidth))
            self.gridTblHdr.tblHdrWraplength = 200 # to  adjust dynamically during configure callbacks
            self.gridTblHdr.tblHdrLabel = \
                gridHdr(self.gridTblHdr, 0, 0, 
                        (self.modelTable.genLabel(lang=self.lang, strip=True) or  # use table label, if any 
                         self.roledefinition),
                        anchor="nw",
                        #columnspan=(self.dataFirstCol - 1),
                        #rowspan=(self.dataFirstRow),
                        wraplength=200) # in screen units
                        #wraplength=sum(self.rowHdrColWidth)) # in screen units
            zAspects = defaultdict(set)
            self.zAxis(1, zTopStructuralNode, zAspects, clearZchoices)
            xStructuralNodes = []
            self.xAxis(self.dataFirstCol, self.colHdrTopRow, self.colHdrTopRow + self.colHdrRows - 1, 
                       xTopStructuralNode, xStructuralNodes, self.xAxisChildrenFirst.get(), True, True)
            self.yAxis(1, self.dataFirstRow,
                       yTopStructuralNode, self.yAxisChildrenFirst.get(), True, True)
            for fp in self.factPrototypes: # dereference prior facts
                if fp is not None:
                    fp.clear()
            self.factPrototypes = []
            self.bodyCells(self.dataFirstRow, yTopStructuralNode, xStructuralNodes, zAspects, self.yAxisChildrenFirst.get())
                
            # data cells
            #print("body cells done")
                
        self.modelXbrl.profileStat("viewTable_" + os.path.basename(viewTblELR), time.time() - startedAt)

        #self.gridView.config(scrollregion=self.gridView.bbox(constants.ALL))
        self.blockMenuEvents -= 1
    def view(self, viewTblELR=None, newInstance=None):
        startedAt = time.time()
        self.blockMenuEvents += 1
        if newInstance is not None:
            self.modelXbrl = newInstance  # a save operation has created a new instance to use subsequently
            clearZchoices = False
        if viewTblELR:  # specific table selection
            self.tblELR = viewTblELR
            clearZchoices = True
        else:  # first or subsequenct reloading (language, dimensions, other change)
            clearZchoices = self.zOrdinateChoices is None
            if clearZchoices:  # also need first time initialization
                self.loadTablesMenu(
                )  # load menus (and initialize if first time
            viewTblELR = self.tblELR

        if not self.tblELR:
            return  # no table to display

        if clearZchoices:
            self.zOrdinateChoices = {}

        # remove old widgets
        self.viewFrame.clearGrid()

        tblAxisRelSet, xTopStructuralNode, yTopStructuralNode, zTopStructuralNode = resolveAxesStructure(
            self, viewTblELR)

        if tblAxisRelSet:
            #print("tbl hdr width rowHdrCols {0}".format(self.rowHdrColWidth))
            self.gridTblHdr.tblHdrWraplength = 200  # to  adjust dynamically during configure callbacks
            self.gridTblHdr.tblHdrLabel = \
                gridHdr(self.gridTblHdr, 0, 0,
                        (self.modelTable.genLabel(lang=self.lang, strip=True) or  # use table label, if any 
                         self.roledefinition),
                        anchor="nw",
                        #columnspan=(self.dataFirstCol - 1),
                        #rowspan=(self.dataFirstRow),
                        wraplength=200) # in screen units
            #wraplength=sum(self.rowHdrColWidth)) # in screen units
            zAspects = defaultdict(set)
            self.zAxis(1, zTopStructuralNode, zAspects, clearZchoices)
            xStructuralNodes = []
            self.xAxis(self.dataFirstCol, self.colHdrTopRow,
                       self.colHdrTopRow + self.colHdrRows - 1,
                       xTopStructuralNode, xStructuralNodes,
                       self.xAxisChildrenFirst.get(), True, True)
            self.yAxis(1, self.dataFirstRow, yTopStructuralNode,
                       self.yAxisChildrenFirst.get(), True, True)
            for fp in self.factPrototypes:  # dereference prior facts
                if fp is not None:
                    fp.clear()
            self.factPrototypes = []
            self.bodyCells(self.dataFirstRow, yTopStructuralNode,
                           xStructuralNodes, zAspects,
                           self.yAxisChildrenFirst.get())

            # data cells
            #print("body cells done")

        self.modelXbrl.profileStat("viewTable_" + os.path.basename(viewTblELR),
                                   time.time() - startedAt)

        #self.gridView.config(scrollregion=self.gridView.bbox(constants.ALL))
        self.blockMenuEvents -= 1
 def view(self, viewTblELR=None):
     if viewTblELR is not None:
         tblELRs = (viewTblELR,)
     else:
         tblELRs = self.modelXbrl.relationshipSet("Table-rendering").linkRoleUris
         
     if self.type == XML:
         self.tblElt.append(etree.Comment("Entry point file: {0}".format(self.modelXbrl.modelDocument.basename)))
     
     for tblELR in tblELRs:
         self.zOrdinateChoices = {}
         
         for discriminator in range(1, 65535):
             tblAxisRelSet, xTopStructuralNode, yTopStructuralNode, zTopStructuralNode = resolveAxesStructure(self, tblELR)
             
             self.zStrNodesWithChoices = []
             if tblAxisRelSet and self.tblElt is not None:
                 tableLabel = (self.modelTable.genLabel(lang=self.lang, strip=True) or  # use table label, if any 
                               self.roledefinition)
                 if self.type == HTML: # table on each Z
                     # each Z is a separate table in the outer table
                     zTableRow = etree.SubElement(self.tblElt, "{http://www.w3.org/1999/xhtml}tr")
                     zRowCell = etree.SubElement(zTableRow, "{http://www.w3.org/1999/xhtml}td")
                     zCellTable = etree.SubElement(zRowCell, "{http://www.w3.org/1999/xhtml}table",
                                                   attrib={"border":"1", "cellspacing":"0", "cellpadding":"4", "style":"font-size:8pt;"})
                     self.rowElts = [etree.SubElement(zCellTable, "{http://www.w3.org/1999/xhtml}tr")
                                     for r in range(self.dataFirstRow + self.dataRows - 1)]
                     etree.SubElement(self.rowElts[0], "{http://www.w3.org/1999/xhtml}th",
                                      attrib={"class":"tableHdr",
                                              "style":"max-width:100em;",
                                              "colspan": str(self.dataFirstCol - 1),
                                              "rowspan": str(self.dataFirstRow - 1)}
                                      ).text = tableLabel
                 elif self.type == XML:
                     self.structuralNodeModelElements = []
                     if discriminator == 1:
                         tableSetElt = etree.SubElement(self.tblElt, tableModelQName("tableSet"))
                         tableSetElt.append(etree.Comment("TableSet linkbase file: {0}, line {1}".format(self.modelTable.modelDocument.basename, self.modelTable.sourceline)))
                         tableSetElt.append(etree.Comment("TableSet namespace: {0}".format(self.modelTable.namespaceURI)))
                         tableSetElt.append(etree.Comment("TableSet linkrole: {0}".format(tblELR)))
                         self.zHdrsElt = etree.SubElement(tableSetElt, tableModelQName("headers"))
                         zAspects = defaultdict(set)
                         self.zAxis(1, zTopStructuralNode, zAspects, True)
                     tableElt = etree.SubElement(tableSetElt, tableModelQName("table"),
                                                 attrib={"label": tableLabel})
                     hdrsElts = dict((disposition,
                                      etree.SubElement(tableElt, tableModelQName("headers"),
                                                       attrib={"disposition": disposition}))
                                     for disposition in ("y", "x"))
                     self.zHdrsElt = hdrsElts["y"]  # z-comments go before y subelement of tableElt
                     # new y,x cells on each Z combination
                     if yTopStructuralNode.childStructuralNodes: # no row header element if no rows
                         self.rowHdrElts = [etree.SubElement(hdrsElts["y"], tableModelQName("header"))
                                            for i in range(self.rowHdrCols - 1 + len(self.rowHdrNonStdRoles))] # self.rowHdrDocCol + self.rowHdrCodeCol)]
                     else:
                         hdrsElts["y"].append(etree.Comment("no rows in this table"))
                     if xTopStructuralNode.childStructuralNodes: # no col header element if no cols
                         self.colHdrElts = [etree.SubElement(hdrsElts["x"], tableModelQName("header"))
                                            for i in range(self.colHdrRows - 1 + len(self.colHdrNonStdRoles))] # self.colHdrDocRow + self.colHdrCodeRow)]
                     else:
                         hdrsElts["x"].append(etree.Comment("no columns in this table"))
                     self.zCells = etree.SubElement(tableElt, tableModelQName("cells"),
                                                       attrib={"disposition": "z"})
                     self.yCells = etree.SubElement(self.zCells, tableModelQName("cells"),
                                                       attrib={"disposition": "y"})
                     ''' move into body cells, for entry row-by-row
                     self.xCells = etree.SubElement(self.yCells, tableModelQName("cells"),
                                                       attrib={"disposition": "x"})
                     '''
                 # rows/cols only on firstTime for infoset XML, but on each time for xhtml
                 zAspects = defaultdict(set)
                 self.zAxis(1, zTopStructuralNode, zAspects, False)
                 xStructuralNodes = []
                 if self.type == HTML or (xTopStructuralNode.childStructuralNodes):
                     self.xAxis(self.dataFirstCol, self.colHdrTopRow, self.colHdrTopRow + self.colHdrRows - 1, 
                                xTopStructuralNode, xStructuralNodes, self.xAxisChildrenFirst.get(), True, True)
                 if self.type == HTML: # table/tr goes by row
                     self.yAxisByRow(1, self.dataFirstRow,
                                     yTopStructuralNode, self.yAxisChildrenFirst.get(), True, True)
                 elif self.type == XML: # infoset goes by col of row header
                     if yTopStructuralNode.childStructuralNodes: # no row header element if no rows
                         self.yAxisByCol(1, self.dataFirstRow,
                                         yTopStructuralNode, self.yAxisChildrenFirst.get(), True, True)
                     for structuralNode,modelElt in self.structuralNodeModelElements: # must do after elements are all arragned
                         modelElt.addprevious(etree.Comment("{0}: label {1}, file {2}, line {3}"
                                                       .format(structuralNode._definitionNode.localName,
                                                               structuralNode._definitionNode.xlinkLabel,
                                                               structuralNode._definitionNode.modelDocument.basename, 
                                                               structuralNode._definitionNode.sourceline)))
                         if structuralNode._definitionNode.get('value'):
                             modelElt.addprevious(etree.Comment("   @value {0}".format(structuralNode._definitionNode.get('value'))))
                         for aspect in sorted(structuralNode.aspectsCovered(), key=lambda a: aspectStr(a)):
                             if structuralNode.hasAspect(aspect) and aspect != Aspect.DIMENSIONS:
                                 aspectValue = structuralNode.aspectValue(aspect)
                                 if aspectValue is None: aspectValue = "(bound dynamically)"
                                 modelElt.addprevious(etree.Comment("   aspect {0}: {1}".format(aspectStr(aspect), aspectValue)))
                         for varName, varValue in structuralNode.variables.items():
                                 modelElt.addprevious(etree.Comment("   variable ${0}: {1}".format(varName, varValue)))
                         
                 self.bodyCells(self.dataFirstRow, yTopStructuralNode, xStructuralNodes, zAspects, self.yAxisChildrenFirst.get())
             # find next choice structural node
             moreDiscriminators = False
             for zStrNodeWithChoices in self.zStrNodesWithChoices:
                 currentIndex = zStrNodeWithChoices.choiceNodeIndex + 1
                 if currentIndex < len(zStrNodeWithChoices.choiceStructuralNodes):
                     zStrNodeWithChoices.choiceNodeIndex = currentIndex
                     self.zOrdinateChoices[zStrNodeWithChoices._definitionNode] = currentIndex
                     moreDiscriminators = True
                     break
                 else:
                     zStrNodeWithChoices.choiceNodeIndex = 0
                     self.zOrdinateChoices[zStrNodeWithChoices._definitionNode] = 0
                     # continue incrementing next outermore z choices index
             if not moreDiscriminators:
                 break