模拟装配导航器treelist代码分享--树控件的使用
tree_control0->InsertColumn(1,"AssemblyName",180);tree_control0->InsertColumn(2,"Status",100);
// get asembly name
BasePart *displayBasepart = theSession->Parts()->BaseDisplay();
Part *workpart = theSession->Parts()->Work();
// get rootcomponent
Assemblies::Component *rootcomponent = displayBasepart->ComponentAssembly()->RootComponent();
if(rootcomponent)
{
Node *parentNode= tree_control0->CreateNode(rootcomponent->DisplayName());
tree_control0->InsertNode(parentNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);
parentNode->SetColumnDisplayText(2,loadStatus(rootcomponent));
getcompoents(parentNode,rootcomponent);
}
else
{
Node *newNode = tree_control0->CreateNode(workpart->Leaf());
newNode->SetDisplayIcon("piecepart");
newNode->SetSelectedIcon("piecepart");
tree_control0->InsertNode(newNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);
newNode->SetColumnDisplayText(2,"loaded piecepart");
delete newNode;
newNode = NULL;
}
}
Node * PNTDemo::createInsertNode(Node *pNode,NXString name,NXString geticon)
{
Node *getNode = tree_control0->CreateNode(name);
getNode->SetDisplayIcon(geticon);
getNode->SetSelectedIcon(geticon);
tree_control0->InsertNode(getNode,pNode,NULL,Tree::NodeInsertOptionLast);
return getNode;
}
NXString PNTDemo::loadStatus(Assemblies::Component *component)
{
Part *part =dynamic_cast<Part*>(component->Prototype());
if(part==NULL_TAG)
{
return "Not Loaded";
}
else
{
if(part->IsFullyLoaded())
return "Fully Loaded";
else
return "Partially Loaded";
}
}
void PNTDemo::getcompoents(Node *parentNode,Assemblies::Component *root)
{
vector <Assemblies::Component *> children = root->GetChildren();
for(int i = 0 ; i < children.size(); i ++)
{
Assemblies::Component *com = children;
Node *newNode = createInsertNode(parentNode,com->DisplayName(),"assembly");
newNode->SetColumnDisplayText(2,loadStatus(com));
getcompoents(newNode,com);
}
}
模拟装配导航器treelist代码分享--树控件的使用
页:
[1]