コード例 #1
0
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    TutorialMouseListener mouseListener;
    TutorialMouseMotionListener mouseMotionListener;
    TutorialWindow->addMouseListener(&mouseListener);
    TutorialWindow->addMouseMotionListener(&mouseMotionListener);

    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);

    // Set up Window

	//Load in File
	NodeRefPtr LoadedFile = SceneFileHandler::the()->read("C:\\Documents and Settings\\All Users\\Documents\\Cell.osb");

    // Make Main Scene Node
    create3DObjects();
    scene = OSG::Node::create();
        scene->setCore(OSG::Group::create());
		scene->addChild(LoadedFile);

    // Create the Graphics
    GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();

    // Initialize the LookAndFeelManager to enable default settings
    LookAndFeelManager::the()->getLookAndFeel()->init();

        
    /******************************************************
            
            Create a Background

    ******************************************************/
    ColorLayerRefPtr GreyBackground = OSG::ColorLayer::create();

        GreyBackground->setColor(Color4f(.93,.93,.93,1.0));


    /******************************************************
            
            Create some Borders

    ******************************************************/
    LineBorderRefPtr PanelBorder = OSG::LineBorder::create();
    EmptyBorderRefPtr Panel1Border = OSG::EmptyBorder::create();
    EmptyBorderRefPtr Panel2Border = OSG::EmptyBorder::create();
    EmptyBorderRefPtr emptyBorder = OSG::EmptyBorder::create();
    
        PanelBorder->setColor(Color4f(0.0,0.0,0.0,1.0));
        PanelBorder->setWidth(1);

        Panel1Border->setTopWidth(0);
        Panel1Border->setBottomWidth(6);
        Panel1Border->setLeftWidth(0);
        Panel1Border->setRightWidth(0);
        Panel2Border->setTopWidth(0);
        Panel2Border->setBottomWidth(0);
        Panel2Border->setLeftWidth(0);
        Panel2Border->setRightWidth(0);
    

    /******************************************************

            Create some Labels and stuff to go 
            with them

    ******************************************************/
    LabelRefPtr LeftPanelLabel1 = OSG::Label::create();
    UIFontRefPtr LeftPanelLabel1Font = OSG::UIFont::create();

        LeftPanelLabel1Font->setSize(50);

        LeftPanelLabel1->setBorders(emptyBorder);
        LeftPanelLabel1->setBackgrounds(GreyBackground);
        LeftPanelLabel1->setFont(LeftPanelLabel1Font);
        LeftPanelLabel1->setText("OSG Gui");
        LeftPanelLabel1->setPreferredSize(Vec2f(300, 100));
		LeftPanelLabel1->setAlignment(Vec2f(0.0f, 0.5f));

     /******************************************************

            Create some Layouts

    ******************************************************/
    BoxLayoutRefPtr MainInternalWindowLayout = OSG::BoxLayout::create();
    FlowLayoutRefPtr LeftPanelLayout = OSG::FlowLayout::create();
    BoxLayoutRefPtr RightPanelLayout = OSG::BoxLayout::create();
        MainInternalWindowLayout->setOrientation(BoxLayout::HORIZONTAL_ORIENTATION);

        LeftPanelLayout->setOrientation(FlowLayout::HORIZONTAL_ORIENTATION);
        LeftPanelLayout->setMinorAxisAlignment(1.0f);

        RightPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION);
    

    /******************************************************

        Create MainFrame and Panels

    ******************************************************/
    PanelRefPtr LeftPanel = OSG::Panel::create();
    PanelRefPtr RightPanel = OSG::Panel::create();

    // LeftPanel stuff
        LeftPanel->setPreferredSize(Vec2f(400, 500));
        LeftPanel->pushToChildren(LeftPanelLabel1);
        LeftPanel->pushToChildren(createLeftPanelButtonPanel());
        LeftPanel->pushToChildren(createLeftPanelRadioTextPanel());
        LeftPanel->setLayout(LeftPanelLayout);
        LeftPanel->setBackgrounds(GreyBackground);
        LeftPanel->setBorders(Panel1Border);

    //RightPanel stuff
        RightPanel->setPreferredSize(Vec2f(200, 620));
        RightPanel->pushToChildren(createRightPanelButtonPanel());
        RightPanel->pushToChildren(createRightPanelCheckPanel());
        RightPanel->setLayout(RightPanelLayout);
        RightPanel->setBackgrounds(GreyBackground);
        RightPanel->setBorders(Panel2Border);
    
    // Create The Main InternalWindow
    InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
       MainInternalWindow->pushToChildren(LeftPanel);
       MainInternalWindow->pushToChildren(RightPanel);
       MainInternalWindow->setLayout(MainInternalWindowLayout);
       MainInternalWindow->setBackgrounds(GreyBackground);
       MainInternalWindow->setBorders(PanelBorder);
	   MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
	   MainInternalWindow->setScalingInDrawingSurface(Vec2f(1.0f,1.0f));
	   MainInternalWindow->setDrawTitlebar(false);
	   MainInternalWindow->setResizable(false);

    // Create the Drawing Surface
    UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);
    
	TutorialDrawingSurface->openWindow(MainInternalWindow);

    // Make A 3D Rectangle to draw the UI on
    UIRectangleRefPtr UIRectCore = UIRectangle::create();
        UIRectCore->setPoint(Pnt3f(-310.0,-310.0,370.0));
        UIRectCore->setWidth(620);
        UIRectCore->setHeight(620);
        UIRectCore->setDrawingSurface(TutorialDrawingSurface);
    
    NodeRefPtr UIRectNode = OSG::Node::create();
        UIRectNode->setCore(UIRectCore);
    
        // add the UIRect as a child
        scene->addChild(UIRectNode);


    mgr->setRoot(scene);

    // 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,
            "21ExampleInterface");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
コード例 #2
0
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;
}
コード例 #3
0
ファイル: 26MenuBar.cpp プロジェクト: Langkamp/OpenSGToolbox
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);

    // Make Torus Node (creates Torus in background of scene)
    NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);

    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addChild(TorusGeometryNode);

    // Create the Graphics
    GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();

    // Initialize the LookAndFeelManager to enable default settings
    LookAndFeelManager::the()->getLookAndFeel()->init();

    /******************************************************

      Create Components to add to MenuBar
      Menus.  Each MenuBar has multiple Menus 
      which contain multiple MenuItems.

      -setAcceleratorKey(KeyEvent::KEY_*): This
      links the key "*" as a shortcut to 
      selecting the item it is attached to.
      An example of this would be Q with 
      Control+Q causing programs to quit.
      -setAcceleratorModifiers(KeyEvent::KEY_MODIFIER_*):
      This adds the "*" key as another 
      requirement to cause the item to be
      selected.  Things such as "CONTROL" are 
      likely to be used here (as mentioned 
      above, both Control and Q are specified).

Note: These shortcuts will be shown in the list
with the MenuItem they are attached to.

-setMnemonicKey(KeyEvent::KEY_****): sets the key
"****" to be underlined within the Menu
itself


     ******************************************************/

    // Creates MenuItems as in 25PopupMenu
    MenuItemRefPtr NewMenuItem = MenuItem::create();
    MenuItemRefPtr OpenMenuItem = MenuItem::create();
    MenuItemRefPtr CloseMenuItem = MenuItem::create();
    MenuItemRefPtr ExitMenuItem = MenuItem::create();
    MenuItemRefPtr UndoMenuItem = MenuItem::create();
    MenuItemRefPtr RedoMenuItem = MenuItem::create();

    //Edits MenuItems
    NewMenuItem->setText("New ...");
    NewMenuItem->setAcceleratorKey(KeyEvent::KEY_N);
    NewMenuItem->setAcceleratorModifiers(KeyEvent::KEY_MODIFIER_COMMAND);
    NewMenuItem->setMnemonicKey(KeyEvent::KEY_N);

    OpenMenuItem->setText("Open ...");
    OpenMenuItem->setAcceleratorKey(KeyEvent::KEY_P);
    OpenMenuItem->setAcceleratorModifiers(KeyEvent::KEY_MODIFIER_COMMAND);
    OpenMenuItem->setMnemonicKey(KeyEvent::KEY_P);

    CloseMenuItem->setText("Close ...");
    CloseMenuItem->setAcceleratorKey(KeyEvent::KEY_W);
    CloseMenuItem->setAcceleratorModifiers(KeyEvent::KEY_MODIFIER_COMMAND);
    CloseMenuItem->setMnemonicKey(KeyEvent::KEY_C);

    ExitMenuItem->setText("Quit");
    ExitMenuItem->setAcceleratorKey(KeyEvent::KEY_Q);
    ExitMenuItem->setAcceleratorModifiers(KeyEvent::KEY_MODIFIER_COMMAND);
    ExitMenuItem->setMnemonicKey(KeyEvent::KEY_Q);

    UndoMenuItem->setText("Undo");
    UndoMenuItem->setAcceleratorKey(KeyEvent::KEY_Z);
    UndoMenuItem->setAcceleratorModifiers(KeyEvent::KEY_MODIFIER_COMMAND);
    UndoMenuItem->setMnemonicKey(KeyEvent::KEY_U);
    RedoMenuItem->setText("Redo");
    RedoMenuItem->setEnabled(false);
    RedoMenuItem->setMnemonicKey(KeyEvent::KEY_R);

    // Create an ActionListener and assign it to ExitMenuItem
    // This is defined above, and will cause the program to quit
    // when that MenuItem is selected or Control + Q hit 
    QuitActionListener TheQuitActionListener;
    ExitMenuItem->addActionListener( &TheQuitActionListener);

    /******************************************************

      Create Menu Components to add to MenuBar
      and adds above Components to them.  

Note: setAcceleratorKey,
setAcceleratorModifiers, and setMnemnoicKey
all apply to Menus in addition to MenuItems.

     ******************************************************/

    // Create a File menu and adds its MenuItems
    MenuRefPtr FileMenu = Menu::create();
    FileMenu->addItem(NewMenuItem);
    FileMenu->addItem(OpenMenuItem);
    FileMenu->addItem(CloseMenuItem);
    FileMenu->addSeparator();
    FileMenu->addItem(ExitMenuItem);

    // Labels the File Menu
    FileMenu->setText("File");
    FileMenu->setMnemonicKey(KeyEvent::KEY_F);

    // Creates an Edit menu and adds its MenuItems
    MenuRefPtr EditMenu = Menu::create();
    EditMenu->addItem(UndoMenuItem);
    EditMenu->addItem(RedoMenuItem);

    // Labels the Edit Menu
    EditMenu->setText("Edit");
    EditMenu->setMnemonicKey(KeyEvent::KEY_E);

    /******************************************************

      Create MainMenuBar and adds the Menus
      created above to it.

      Also creates several Backgrounds
      to improve MenuBar overall look.
      Both the MenuBar and Menu can have
      Backgrounds; the set up currently
      is to have EmptyBackgrounds in 
      each Menu allowing a single
      overall MenuBar Background which
      is given to the MenuBar itself.

      This can be easily changed by adding
      different Backgrounds to the 
      File and Edit Menus.

Note: The MenuBar is added to the
MainFrame below.

     ******************************************************/
    // Creates two Backgrounds

    MenuBarRefPtr MainMenuBar = MenuBar::create();
    // Adds the two Menus to the MainMenuBar
    MainMenuBar->addMenu(FileMenu);
    MainMenuBar->addMenu(EditMenu);

    // Create two Labels
    LabelRefPtr ExampleLabel1 = OSG::Label::create();
    LabelRefPtr ExampleLabel2 = OSG::Label::create();

    ExampleLabel1->setText("Look up in the corner!");
    ExampleLabel1->setPreferredSize(Vec2f(150, 25));    

    ExampleLabel2->setText("Hit Control + Z");
    ExampleLabel2->setPreferredSize(Vec2f(150, 25));    

    // Create The Main InternalWindow
    // Create Background to be used with the Main InternalWindow
    EmptyLayerRefPtr MainInternalWindowBackground = OSG::EmptyLayer::create();
    EmptyBorderRefPtr MainInternalWindowBorder = OSG::EmptyBorder::create();

    LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();

    InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
    MainInternalWindow->pushToChildren(ExampleLabel1);
    MainInternalWindow->pushToChildren(ExampleLabel2);
    MainInternalWindow->setLayout(MainInternalWindowLayout);
    MainInternalWindow->setMenuBar(MainMenuBar);
    MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
    MainInternalWindow->setBorders(MainInternalWindowBorder);
    MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
    MainInternalWindow->setScalingInDrawingSurface(Vec2f(1.0f,1.0f));
    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(scene);

    // 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,
                               "26MenuBar");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}