void HelperPanel::createIntrospectionTreeTab(TabPanel* const tabPanel) { BorderLayoutConstraintsRefPtr CenterConstraints = OSG::BorderLayoutConstraints::create(); CenterConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER); BorderLayoutConstraintsRefPtr NorthConstraints = OSG::BorderLayoutConstraints::create(); NorthConstraints->setRegion(BorderLayoutConstraints::BORDER_NORTH); _GlobalLuaIntroTreeModel = LuaIntrospectionTreeModel::create(); _GlobalLuaIntroTreeModel->setRoot(""); LuaIntrospectionComponentGeneratorRecPtr LuaIntroTreeComponentGenerator = LuaIntrospectionComponentGenerator::create(); //Create the Tree TreeRecPtr TheTree = Tree::create(); TheTree->setPreferredSize(Vec2f(200, 500)); TheTree->setModel(_GlobalLuaIntroTreeModel); TheTree->setCellGenerator(LuaIntroTreeComponentGenerator); //Layout Expansion TheTree->expandPath(_GlobalLuaIntroTreeModel->getRootPath()); //Create a scroll panel for the tree ScrollPanelRefPtr TreeScrollPanel = ScrollPanel::create(); TreeScrollPanel->setPreferredSize(Vec2f(200,300)); TreeScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW); TreeScrollPanel->setViewComponent(TheTree); TreeScrollPanel->setConstraints(CenterConstraints); //Global Label LabelRecPtr GlobalTreeLabel = Label::create(); GlobalTreeLabel->setText("Global"); GlobalTreeLabel->setConstraints(NorthConstraints); BorderLayoutRecPtr BorderPanelLayout = BorderLayout::create(); //Global Panel PanelRecPtr GlobalLuaTreePanel = Panel::createEmpty(); GlobalLuaTreePanel->pushToChildren(GlobalTreeLabel); GlobalLuaTreePanel->pushToChildren(TreeScrollPanel); GlobalLuaTreePanel->setLayout(BorderPanelLayout); //Local Label LabelRecPtr LocalTreeLabel = Label::create(); LocalTreeLabel->setText("Local"); LocalTreeLabel->setConstraints(NorthConstraints); //Local Panel PanelRecPtr LocalLuaTreePanel = Panel::createEmpty(); LocalLuaTreePanel->pushToChildren(LocalTreeLabel); LocalLuaTreePanel->setLayout(BorderPanelLayout); //Global/Local Split Panel SplitPanelRecPtr GlocalLocalSplitPanel = SplitPanel::create(); GlocalLocalSplitPanel->setMinComponent(GlobalLuaTreePanel); GlocalLocalSplitPanel->setMaxComponent(LocalLuaTreePanel); GlocalLocalSplitPanel->setDividerPosition(0.5f); GlocalLocalSplitPanel->setDividerSize(5); GlocalLocalSplitPanel->setMinDividerPosition(.1); GlocalLocalSplitPanel->setMaxDividerPosition(.9); //Add the Panel to the TabPanel LabelRefPtr IntrospectionTreeTabLabel = Label::create(); IntrospectionTreeTabLabel->setText("Lua Introspection"); IntrospectionTreeTabLabel->setBorders(NULL); IntrospectionTreeTabLabel->setBackgrounds(NULL); tabPanel->addTab(IntrospectionTreeTabLabel, GlocalLocalSplitPanel); }
int main(int argc, char **argv) { // OSG init osgInit(argc,argv); // Set up Window TutorialWindow = createNativeWindow(); TutorialWindow->initWindow(); TutorialWindow->setDisplayCallback(display); TutorialWindow->setReshapeCallback(reshape); TutorialKeyListener TheKeyListener; TutorialWindow->addKeyListener(&TheKeyListener); NodeRefPtr Root(NULL); if(argc == 2) { Root = SceneFileHandler::the()->read(argv[1]); } if(Root == NULL) { // Make Torus Node (creates Torus in background of Root) NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16); setName(TorusGeometryNode, std::string("Torus")); NodeRefPtr TorusNode = Node::create(); TorusNode->setCore(OSG::Transform::create()); TorusNode->addChild(TorusGeometryNode); setName(TorusNode, std::string("Torus Transform")); NodeRefPtr SphereGeometryNode = makeSphere(2,1.0f); setName(SphereGeometryNode, std::string("Sphere")); NodeRefPtr BoxGeometryNode = makeBox(1.0,1.0,1.0,1,1,1); setName(BoxGeometryNode, std::string("Box")); // Make Main Scene Node and add the Torus Root = OSG::Node::create(); Root->setCore(OSG::Group::create()); Root->addChild(TorusNode); Root->addChild(SphereGeometryNode); Root->addChild(BoxGeometryNode); setName(Root, std::string("Root")); } // Create the Graphics GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create(); // Initialize the LookAndFeelManager to enable default settings LookAndFeelManager::the()->getLookAndFeel()->init(); //Tree Model TheTreeModel = SceneGraphTreeModel::create(); TheTreeModel->setRoot(Root); //TheFileSystemTreeModel = FileSystemTreeModel::create(); //TheFileSystemTreeModel->setRoot(BoostPath("C:\\")); //TheFileSystemTreeModel->setRoot(BoostPath("/")); //Create the Tree TheTree = Tree::create(); TheTree->setPreferredSize(Vec2f(100, 500)); TheTree->setModel(TheTreeModel); //TheTree->setModel(TheFileSystemTreeModel); TutorialTreeSelectionListener TheTutorialTreeSelectionListener; TheTree->getSelectionModel()->addTreeSelectionListener(&TheTutorialTreeSelectionListener); // Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel) BorderLayoutConstraintsRefPtr SceneTreeConstraints = OSG::BorderLayoutConstraints::create(); SceneTreeConstraints->setRegion(BorderLayoutConstraints::BORDER_WEST); ScrollPanelRefPtr ExampleScrollPanel = ScrollPanel::create(); ExampleScrollPanel->setPreferredSize(Vec2f(350,300)); ExampleScrollPanel->setConstraints(SceneTreeConstraints); //ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW); //ExampleScrollPanel->setVerticalResizePolicy(ScrollPanel::RESIZE_TO_VIEW); ExampleScrollPanel->setViewComponent(TheTree); //Details Panel Labels LabelRefPtr NodeNameLabel = Label::create(); NodeNameLabel->setText("Name"); NodeNameLabel->setPreferredSize(Vec2f(100.0f, 20.0f)); NodeNameValueLabel = Label::create(); NodeNameValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f)); LabelRefPtr NodeCoreTypeLabel = Label::create(); NodeCoreTypeLabel->setText("Core Type"); NodeCoreTypeLabel->setPreferredSize(Vec2f(100.0f, 20.0f)); NodeCoreTypeValueLabel = Label::create(); NodeCoreTypeValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f)); LabelRefPtr NodeMinLabel = Label::create(); NodeMinLabel->setText("Min"); NodeMinLabel->setPreferredSize(Vec2f(100.0f, 20.0f)); NodeMinValueLabel = Label::create(); NodeMinValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f)); LabelRefPtr NodeMaxLabel = Label::create(); NodeMaxLabel->setText("Max"); NodeMaxLabel->setPreferredSize(Vec2f(100.0f, 20.0f)); NodeMaxValueLabel = Label::create(); NodeMaxValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f)); LabelRefPtr NodeCenterLabel = Label::create(); NodeCenterLabel->setText("Center"); NodeCenterLabel->setPreferredSize(Vec2f(100.0f, 20.0f)); NodeCenterValueLabel = Label::create(); NodeCenterValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f)); LabelRefPtr NodeTriCountLabel = Label::create(); NodeTriCountLabel->setText("TriCount"); NodeTriCountLabel->setPreferredSize(Vec2f(100.0f, 20.0f)); NodeTriCountValueLabel = Label::create(); NodeTriCountValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f)); LabelRefPtr NodeTravMaskLabel = Label::create(); NodeTravMaskLabel->setText("Traversal Mask"); NodeTravMaskLabel->setPreferredSize(Vec2f(100.0f, 20.0f)); NodeTravMaskValueLabel = Label::create(); NodeTravMaskValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f)); LabelRefPtr NodeOcclusionMaskLabel = Label::create(); NodeOcclusionMaskLabel->setText("Occlusion Mask"); NodeOcclusionMaskLabel->setPreferredSize(Vec2f(100.0f, 20.0f)); NodeOcclusionMaskValueLabel = Label::create(); NodeOcclusionMaskValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f)); LabelRefPtr NodeActiveLabel = Label::create(); NodeActiveLabel->setText("Active"); NodeActiveLabel->setPreferredSize(Vec2f(100.0f, 20.0f)); NodeActiveValueLabel = Label::create(); NodeActiveValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f)); //Details Panel BorderLayoutConstraintsRefPtr NodeDetailPanelConstraints = OSG::BorderLayoutConstraints::create(); NodeDetailPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_SOUTH); GridLayoutRefPtr NodeDetailPanelLayout = OSG::GridLayout::create(); NodeDetailPanelLayout->setRows(9); NodeDetailPanelLayout->setColumns(2); NodeDetailPanelLayout->setHorizontalGap(2); NodeDetailPanelLayout->setVerticalGap(2); PanelRefPtr NodeDetailPanel = Panel::create(); NodeDetailPanel->setConstraints(NodeDetailPanelConstraints); NodeDetailPanel->setPreferredSize(Vec2f(100.0f, 200.0f)); NodeDetailPanel->setLayout(NodeDetailPanelLayout); NodeDetailPanel->pushToChildren(NodeNameLabel); NodeDetailPanel->pushToChildren(NodeNameValueLabel); NodeDetailPanel->pushToChildren(NodeCoreTypeLabel); NodeDetailPanel->pushToChildren(NodeCoreTypeValueLabel); NodeDetailPanel->pushToChildren(NodeMinLabel); NodeDetailPanel->pushToChildren(NodeMinValueLabel); NodeDetailPanel->pushToChildren(NodeMaxLabel); NodeDetailPanel->pushToChildren(NodeMaxValueLabel); NodeDetailPanel->pushToChildren(NodeCenterLabel); NodeDetailPanel->pushToChildren(NodeCenterValueLabel); NodeDetailPanel->pushToChildren(NodeTriCountLabel); NodeDetailPanel->pushToChildren(NodeTriCountValueLabel); NodeDetailPanel->pushToChildren(NodeTravMaskLabel); NodeDetailPanel->pushToChildren(NodeTravMaskValueLabel); NodeDetailPanel->pushToChildren(NodeOcclusionMaskLabel); NodeDetailPanel->pushToChildren(NodeOcclusionMaskValueLabel); NodeDetailPanel->pushToChildren(NodeActiveLabel); NodeDetailPanel->pushToChildren(NodeActiveValueLabel); // Create The Main InternalWindow // Create Background to be used with the Main InternalWindow ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create(); MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5)); LayoutRefPtr MainInternalWindowLayout = OSG::BorderLayout::create(); InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create(); MainInternalWindow->pushToChildren(ExampleScrollPanel); MainInternalWindow->pushToChildren(NodeDetailPanel); MainInternalWindow->setLayout(MainInternalWindowLayout); MainInternalWindow->setBackgrounds(NULL); MainInternalWindow->setBorders(NULL); MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.0f,0.5f)); MainInternalWindow->setScalingInDrawingSurface(Vec2f(1.0,1.0)); MainInternalWindow->setDrawTitlebar(false); MainInternalWindow->setResizable(false); // Create the Drawing Surface UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create(); TutorialDrawingSurface->setGraphics(TutorialGraphics); TutorialDrawingSurface->setEventProducer(TutorialWindow); TutorialDrawingSurface->openWindow(MainInternalWindow); // Create the UI Foreground Object UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create(); TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface); // Create the SimpleSceneManager helper mgr = new SimpleSceneManager; // Tell the Manager what to manage mgr->setWindow(TutorialWindow); mgr->setRoot(Root); // Add the UI Foreground Object to the Scene ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0); TutorialViewport->addForeground(TutorialUIForeground); // Show the whole Scene mgr->showAll(); //Open Window Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f); Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5); TutorialWindow->openWindow(WinPos, WinSize, "52SceneGraphTree"); //Enter main Loop TutorialWindow->mainLoop(); osgExit(); return 0; }