Package diffpy :: Package pdfgui :: Package gui :: Module fittree :: Class FitTree
[hide private]
[frames] | no frames]

Class FitTree

source code

     object --+                    
              |                    
wx._core.Object --+                
                  |                
wx._core.EvtHandler --+            
                      |            
        wx._core.Window --+        
                          |        
           wx._core.Control --+    
                              |    
          wx._controls.TreeCtrl --+
                                  |
                                 FitTree

TreeCtrl designed to organize pdffit fits.

The root of the tree is hidden. Below that there are several levels
which are diagrammed below.

_ fit (*)
|
|____ phase (5)
|____ datset (*)
|____ calculation (*)

Fits are at the top level. Under fits there are phases, datasets, and
calculations (in that order).

It is required that the data for each node is a dictionary. In the 'type'
entry of this dictionary is the node type (fit, phase, dataset,
calculation). Fit items also have a 'cdata' entry in their tree item
dictionary. This is the control center data associated with this node's
branch.

Data members:
control     --  The pdfguicontrol object that interfaces between the tree
                and the pdffit2 engine. The tree is a mirror of the internal
                structure of the control.



Instance Methods [hide private]
 
__init__(self, parent, id=-1, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=2081, validator=<wx._core.Validator; proxy of <Swig Object of type 'wxValidato..., name='FitTree')
__init__(self, Window parent, int id=-1, Point pos=DefaultPosition, ...
source code
 
InitializeTree(self)
This initializes the tree by adding a root node.
source code
 
GetTreeItemDict(self, node)
Get the data dictionary of the node.
source code
 
GetFitRoot(self, node)
Return the id of the fit in which the passed node resides.
source code
 
GetChildren(self, node)
Get the ids of the children of a given node.
source code
 
GetSiblings(self, node)
Get the ids of the siblings of a given node.
source code
 
GetAllType(self, node)
Get the id of each item in the tree of the same type as node.
source code
 
GetPhases(self, node)
Get a list of phase in branch.
source code
 
GetDataSets(self, node)
Get a list of datasets in branch.
source code
 
GetCalculations(self, node)
Get a list of calculations in branch.
source code
 
GetNodeType(self, node)
Get the node type.
source code
 
SetNodeType(self, node, type)
Set the node type of a node.
source code
 
GetBranchName(self, node)
Get the name of the branch in which node resides.
source code
 
GetLastPhase(self, node)
Get the last phase child of the parent node.
source code
 
GetLastDataSet(self, node)
Get the last dataset child of the fit node.
source code
 
GetNumPhases(self, node)
Get the number of phases in a branch.
source code
 
GetNumDataSets(self, node)
Get the number of datasets in a branch.
source code
 
GetPositionInSubtree(self, node)
Get the index if the node in its subtree.
source code
 
SetControlData(self, node, data)
Set the control center data associated with the node.
source code
 
GetControlData(self, node)
Get the control center data associated with a node.
source code
 
AddFit(self, fitname='Fit 1', cdata=None, paste=False)
Append a new fit tree to the end of the current fits.
source code
 
AddPhase(self, node, label, insertafter=None, filename=None, makedata=True, cdata=None)
Add a new blank Phase to the tree as a child of node.
source code
 
AddDataSet(self, node, label, insertafter=None, filename=None, makedata=True, cdata=None)
Add a new DataSet to the tree as a child of fit.
source code
 
AddCalc(self, node, label, insertafter=None, makedata=True, cdata=None)
Add a new DataSet to the tree as a child of fit.
source code
 
CopyBranch(self, startnode)
Make a copy of a tree branch.
source code
 
GetClipboard(self)
Get the clipboard data.
source code
 
PasteBranch(self, entrypoint=None)
Paste the branch from the clipboard into tree at the given node.
source code
 
__copyLabel(self, oldlabel, entrypoint)
Make a new label that is appropriate for a new node.
source code
 
__InsertBranch(self, cdata, entrypoint, label, insertafter=None, prepend=False)
Instert control data into the tree.
source code
 
DeleteBranches(self, selections)
Remove the subtree starting from the selected node(s).
source code
 
SelectAll(self)
Select all nodes.
source code
 
SelectAllType(self, node=None)
Select all nodes of same type as passed node.
source code
 
ExtendProjectTree(self, treelist, clear=True, paste=False)
Extend the project tree from the treelist.
source code

Inherited from wx._controls.TreeCtrl: AddRoot, AppendItem, AssignImageList, AssignStateImageList, Collapse, CollapseAll, CollapseAllChildren, CollapseAndReset, Create, Delete, DeleteAllItems, DeleteChildren, EditLabel, EnsureVisible, Expand, ExpandAll, ExpandAllChildren, GetBoundingRect, GetChildrenCount, GetCount, GetEditControl, GetFirstChild, GetFirstVisibleItem, GetImageList, GetIndent, GetItemBackgroundColour, GetItemData, GetItemFont, GetItemImage, GetItemParent, GetItemPyData, GetItemText, GetItemTextColour, GetLastChild, GetNextChild, GetNextSibling, GetNextVisible, GetPrevSibling, GetPrevVisible, GetPyData, GetQuickBestSize, GetRootItem, GetSelection, GetSelections, GetSpacing, GetStateImageList, HitTest, InsertItem, InsertItemBefore, IsBold, IsEmpty, IsExpanded, IsSelected, IsVisible, ItemHasChildren, PrependItem, ScrollTo, SelectItem, SetImageList, SetIndent, SetItemBackgroundColour, SetItemBold, SetItemData, SetItemDropHighlight, SetItemFont, SetItemHasChildren, SetItemImage, SetItemPyData, SetItemText, SetItemTextColour, SetPyData, SetQuickBestSize, SetSpacing, SetStateImageList, SortChildren, Toggle, ToggleItemSelection, Unselect, UnselectAll, UnselectItem, __repr__

Inherited from wx._controls.TreeCtrl (private): _setCallbackInfo

Inherited from wx._core.Control: Command, GetAlignment, GetLabelText

Inherited from wx._core.Window: AcceptsFocus, AcceptsFocusFromKeyboard, AddChild, AdjustForLayoutDirection, AssociateHandle, CacheBestSize, CanSetTransparent, CaptureMouse, Center, CenterOnParent, Centre, CentreOnParent, ClearBackground, ClientToScreen, ClientToScreenXY, Close, ConvertDialogPointToPixels, ConvertDialogSizeToPixels, ConvertPixelPointToDialog, ConvertPixelSizeToDialog, DLG_PNT, DLG_SZE, Destroy, DestroyChildren, Disable, DissociateHandle, DragAcceptFiles, Enable, FindWindowById, FindWindowByName, Fit, FitInside, Freeze, GetAcceleratorTable, GetAdjustedBestSize, GetAutoLayout, GetBackgroundColour, GetBackgroundStyle, GetBestFittingSize, GetBestSize, GetBestSizeTuple, GetBestVirtualSize, GetBorder, GetCaret, GetCharHeight, GetCharWidth, GetClientAreaOrigin, GetClientRect, GetClientSize, GetClientSizeTuple, GetConstraints, GetContainingSizer, GetCursor, GetDefaultAttributes, GetDropTarget, GetEffectiveMinSize, GetEventHandler, GetExtraStyle, GetFont, GetForegroundColour, GetFullTextExtent, GetGrandParent, GetGtkWidget, GetHandle, GetHelpText, GetHelpTextAtPoint, GetId, GetLabel, GetLayoutDirection, GetMaxHeight, GetMaxSize, GetMaxWidth, GetMinHeight, GetMinSize, GetMinWidth, GetName, GetParent, GetPosition, GetPositionTuple, GetRect, GetScreenPosition, GetScreenPositionTuple, GetScreenRect, GetScrollPos, GetScrollRange, GetScrollThumb, GetSize, GetSizeTuple, GetSizer, GetTextExtent, GetThemeEnabled, GetToolTip, GetTopLevelParent, GetUpdateClientRect, GetUpdateRegion, GetValidator, GetVirtualSize, GetVirtualSizeTuple, GetWindowBorderSize, GetWindowStyle, GetWindowStyleFlag, GetWindowVariant, HasCapture, HasFlag, HasMultiplePages, HasScrollbar, HasTransparentBackground, Hide, HitTestXY, InheritAttributes, InheritsBackgroundColour, InitDialog, InvalidateBestSize, IsBeingDeleted, IsDoubleBuffered, IsEnabled, IsExposed, IsExposedPoint, IsExposedRect, IsFrozen, IsRetained, IsShown, IsShownOnScreen, IsTopLevel, Layout, LineDown, LineUp, Lower, MakeModal, Move, MoveAfterInTabOrder, MoveBeforeInTabOrder, MoveXY, Navigate, PageDown, PageUp, PopEventHandler, PopupMenu, PopupMenuXY, PostCreate, PrepareDC, PushEventHandler, Raise, Refresh, RefreshRect, RegisterHotKey, ReleaseMouse, RemoveChild, RemoveEventHandler, Reparent, ScreenToClient, ScreenToClientXY, ScrollLines, ScrollPages, ScrollWindow, SendSizeEvent, SetAcceleratorTable, SetAutoLayout, SetBackgroundColour, SetBackgroundStyle, SetBestFittingSize, SetCaret, SetClientRect, SetClientSize, SetClientSizeWH, SetConstraints, SetContainingSizer, SetCursor, SetDimensions, SetDoubleBuffered, SetDropTarget, SetEventHandler, SetExtraStyle, SetFocus, SetFocusFromKbd, SetFont, SetForegroundColour, SetHelpText, SetHelpTextForId, SetId, SetInitialSize, SetLabel, SetLayoutDirection, SetMaxSize, SetMinSize, SetName, SetOwnBackgroundColour, SetOwnFont, SetOwnForegroundColour, SetPosition, SetRect, SetScrollPos, SetScrollbar, SetSize, SetSizeHints, SetSizeHintsSz, SetSizeWH, SetSizer, SetSizerAndFit, SetThemeEnabled, SetToolTip, SetToolTipString, SetTransparent, SetValidator, SetVirtualSize, SetVirtualSizeHints, SetVirtualSizeHintsSz, SetVirtualSizeWH, SetWindowStyle, SetWindowStyleFlag, SetWindowVariant, ShouldInheritColours, Show, Thaw, ToggleWindowStyle, TransferDataFromWindow, TransferDataToWindow, UnregisterHotKey, Update, UpdateWindowUI, UseBgCol, Validate, WarpPointer

Inherited from wx._core.EvtHandler: AddPendingEvent, Bind, Connect, Disconnect, GetEvtHandlerEnabled, GetNextHandler, GetPreviousHandler, ProcessEvent, ProcessPendingEvents, SetEvtHandlerEnabled, SetNextHandler, SetPreviousHandler, Unbind

Inherited from wx._core.EvtHandler (private): _setOORInfo

Inherited from wx._core.Object: GetClassName, IsSameAs

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Static Methods [hide private]

Inherited from wx._controls.TreeCtrl: GetClassDefaultAttributes

Inherited from wx._core.Window: FindFocus, GetCapture, NewControlId, NextControlId, PrevControlId

Properties [hide private]

Inherited from wx._controls.TreeCtrl: Count, EditControl, FirstVisibleItem, ImageList, Indent, QuickBestSize, RootItem, Selection, Selections, Spacing, StateImageList, thisown

Inherited from wx._core.Control: Alignment, LabelText

Inherited from wx._core.Window: AcceleratorTable, AutoLayout, BackgroundColour, BackgroundStyle, BestSize, BestVirtualSize, Border, Caret, CharHeight, CharWidth, Children, ClientAreaOrigin, ClientRect, ClientSize, Constraints, ContainingSizer, Cursor, DefaultAttributes, DropTarget, EffectiveMinSize, Enabled, EventHandler, ExtraStyle, Font, ForegroundColour, GrandParent, GtkWidget, Handle, HelpText, Id, Label, LayoutDirection, MaxHeight, MaxSize, MaxWidth, MinHeight, MinSize, MinWidth, Name, Parent, Position, Rect, ScreenPosition, ScreenRect, Shown, Size, Sizer, ThemeEnabled, ToolTip, TopLevel, TopLevelParent, UpdateClientRect, UpdateRegion, Validator, VirtualSize, WindowStyle, WindowStyleFlag, WindowVariant

Inherited from wx._core.EvtHandler: EvtHandlerEnabled, NextHandler, PreviousHandler

Inherited from wx._core.Object: ClassName

Inherited from object: __class__

Method Details [hide private]

__init__(self, parent, id=-1, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=2081, validator=<wx._core.Validator; proxy of <Swig Object of type 'wxValidato..., name='FitTree')
(Constructor)

source code 

__init__(self, Window parent, int id=-1, Point pos=DefaultPosition, 
    Size size=DefaultSize, long style=TR_DEFAULT_STYLE, 
    Validator validator=DefaultValidator, 
    String name=TreeCtrlNameStr) -> TreeCtrl

Overrides: wx._controls.TreeCtrl.__init__
(inherited documentation)

GetChildren(self, node)

source code 
Get the ids of the children of a given node.

Returns:
WindowList

Overrides: wx._core.Window.GetChildren

GetPhases(self, node)

source code 
Get a list of phase in branch.

node is either the fit-root or a node in the fit-branch of interest.

GetDataSets(self, node)

source code 
Get a list of datasets in branch.

node is either the fit-root or a node in the fit-branch of interest.

GetCalculations(self, node)

source code 
Get a list of calculations in branch.

node is either the fit-root or a node in the fit-branch of interest.

GetNodeType(self, node)

source code 
Get the node type.

This is the "type" entry in the data dictionary of the node.

GetLastPhase(self, node)

source code 
Get the last phase child of the parent node.

This method is helpful in placing datasets and phases into the fit tree.
This method depends on the fact that phases are placed before datasets
in the fit tree.

GetLastDataSet(self, node)

source code 
Get the last dataset child of the fit node.

If there is no last dataset node, this may return the last phase node.
The purpose of getting this node is to know where to place another node,
so the actual node type is not important.

GetNumPhases(self, node)

source code 
Get the number of phases in a branch.

node    --  A node in the branch, or the root of the branch.

GetNumDataSets(self, node)

source code 
Get the number of datasets in a branch.

node    --  A node in the branch, or the root of the branch.

GetPositionInSubtree(self, node)

source code 
Get the index if the node in its subtree.

For fits the position is absolute within the tree. For phases, datasets,
and calculations, the location is taken to be in reference to the other
nodes of its type. This is designed to be compatible with the control
center.

SetControlData(self, node, data)

source code 
Set the control center data associated with the node.

This need only be called for 'fit' nodes.
This is the "cdata" entry in the data dictionary of the
node. It holds the object with which the right panel interfaces. For
example, for a 'phase' node, it contains a Structure object.

GetControlData(self, node)

source code 
Get the control center data associated with a node.

NOTE: The fit-root of a node holds this data. This method makes it
convenient to retrieve it.

AddFit(self, fitname='Fit 1', cdata=None, paste=False)

source code 
Append a new fit tree to the end of the current fits.

fitname     --  The name of the fit. This is incremented if it already
                exists.
cdata       --  Control data for the node. If cdata is None (default),
                then the control is asked to create new data.
paste       --  Whether or not the cdata is being pasted from another
                node (default False).

Returns the id of the new node.

AddPhase(self, node, label, insertafter=None, filename=None, makedata=True, cdata=None)

source code 
Add a new blank Phase to the tree as a child of node.

node        --  The parent 'fit' node.
label       --  The name of the new node. 
insertafter --  The node after which to insert the new phase. If
                insertafter is None (default) the new phase is
                appended to the end of the phases in the subtree of
                the parent node.
filename    --  The file from which to load the structure. If this is
                None (default), a new structure is created.
makedata    --  Tells whether the control needs to make data for the
                node (default True).
cdata       --  Control data for the node. If cdata is None (default),
                then it is assumed that the node already has data in the
                control. See ExtendProjectTree and __InsertBranch for
                examples of how this is used.

Phases are always placed before DataSets.

Raises:
    FitTreeError if node is not a "fit" node.
    FitTreeError if insertafter is not a "phase" node.

Returns the id of the new node.

AddDataSet(self, node, label, insertafter=None, filename=None, makedata=True, cdata=None)

source code 
Add a new DataSet to the tree as a child of fit. 

node        --  The parent node of the dataset. Must be 'fit' type.
label       --  The label of the new node.
insertafter --  The node after which to insert the new dataset. If
                insertafter is None (default) the new dataset is
                appended to the end of the datasets in the subtree of
                the parent node.
filename    --  The name of the file from which to load the data.
makedata    --  Tells whether the control needs to make data for the
                node (default True). If True, cdata is ignored.
cdata       --  Control data for the node. If False cdata is None
                (default), then it is assumed that the node already has
                data in the control. See ExtendProjectTree and
                __InsertBranch for examples of how this is used.

DataSets are always placed after Phases.

Raises:
    FitTreeError if node is not a "fit" node.
    FitTreeError if insertafter is not a "dataset" node.

Returns the id of the new node.

AddCalc(self, node, label, insertafter=None, makedata=True, cdata=None)

source code 
Add a new DataSet to the tree as a child of fit. 

node        --  The parent node of the calculation. Must be 'fit' type.
label       --  The label of the new node.
insertafter --  The node after which to insert the new calculation. If
                insertafter is None (default) the new calculation is
                appended to the end of the calculation in the subtree of
                the parent node.
makedata    --  Tells whether the control needs to make data for the
                node (default True). If True, cdata is ignored.
cdata       --  Control data for the node. If False cdata is None
                (default), then it is assumed that the node already has
                data in the control. See ExtendProjectTree and
                __InsertBranch for examples of how this is used.

Calculations are always placed after datasets.

Raises:
    FitTreeError if node is not a "fit" node.
    FitTreeError if insertafter is not a "calculation" node.

Returns the id of the new node.

CopyBranch(self, startnode)

source code 
Make a copy of a tree branch.

The branch is held in the system clipboard so it can be used in another
instance of the fittree.

GetClipboard(self)

source code 
Get the clipboard data.

Returns the controldata in the clipboard, or None if the clipboard is
empty or contains the wrong type of data.

PasteBranch(self, entrypoint=None)

source code 
Paste the branch from the clipboard into tree at the given node.

A certain type of branch can only be copied to specific places.

fit         -   A fit can be pasted to anywhere. This does not overwrite 
                an existing node, but simply inserts the fit into the
                last available slot.
phase       -   A phase can be pasted from anywhere. If pasted from a
                fit, it is placed at the end of the phase section of
                that node. If inserted from a dataset or a calculation,
                it is placed at the end of the phase section.
dataset     -   A dataset can be pasted from anywhere. If pasted from a
                fit, the dataset is appended at the end of the other
                datasets. If pasted from a dataset, the pasted set is
                inserted right after that one. If pasted from a phase,
                it is placed at the beginning of the dataset section. If
                pasted from a calculation, it is placed at the end of
                the dataset section.
calculation -   A calculation can be pasted to anywhere, but it appears
                at the end of the calculation section of the tree. If
                pasted from a calculation node, it is inserted after
                that node.

Raises:
    FitTreeError if the entrypoint and branch type are incompatible.

__InsertBranch(self, cdata, entrypoint, label, insertafter=None, prepend=False)

source code 
Instert control data into the tree. 

cdata       --  The control data that goes with the branch
entrypoint  --  The subbranch (fit root) to paste into
label       --  The label of the new node
insertafter --  A node after which to insert. If insertafter is None
                (default), then the new node will be pasted after the
                last node of the same type.
prepend     --  Prepend to the beginning of the node group (default
                False). insertafter takes prescedent over prepend.

Returns the newly inserted node.

SelectAllType(self, node=None)

source code 
Select all nodes of same type as passed node.

node    --  Node whose type to select. If node is None (default), then
            all fit nodes will be selected.

ExtendProjectTree(self, treelist, clear=True, paste=False)

source code 
Extend the project tree from the treelist.

treelist    --  A list of control data returned by
                Oraganizer.organization()
clear       --  Clear the tree before adding new nodes (default True)
paste       --  Whether or not the cdata is being pasted from another
                node (default False).

The treelist here is of the type returned from pdfguicontrol.load.
It is a list of fit lists with the following format.
node[0]     --  fit object
node[1]     --  list of (name, dataset) tuples
node[2]     --  list of (name, phase) tuples
node[3]     --  list of (name, calculation) tuples

Note that node[1] should be empty if the node is a calculation.

Returns the last insterted fit or calculation node